package club.xyes.zkh.ecommerce.common.vo;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Collection;

import static org.springframework.http.HttpStatus.OK;

/**
 * Create by 郭文梁 2019/4/15 0015 15:29
 * GeneralCollectionResult
 * 通用多数据（数组）返回对象
 *
 * @author 郭文梁
 * @data 2019/4/15 0015
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class GeneralCollectionResult<T> extends GeneralResult<Collection<T>> {
    public GeneralCollectionResult() {
        super();
    }

    public GeneralCollectionResult(int code, String msg, Collection<T> data) {
        super(code, msg, data);
    }


    public static <T> GeneralCollectionResult<T> of(int code, String msg, Collection<T> data) {
        return new GeneralCollectionResult<>(code, msg, data);
    }

    public static <T> GeneralCollectionResult<T> of(int coe, String msg) {
        return of(coe, msg, null);
    }

    public static <T> GeneralCollectionResult<T> ok(String msg, Collection<T> data) {
        return of(OK.value(), msg, data);
    }

    public static <T> GeneralCollectionResult<T> ok(Collection<T> data) {
        return ok(OK.name(), data);
    }
}
